<template>
  <rx-layout>
    <div slot="center" style>
      <rx-fit>
        <div slot="toolheader" foldheader="true" foldbtn="true" border="false">
          <div class="table-page-search-wrapper">
            <a-form layout="inline">
              <a-row :gutter="24">
                    <a-col :span="8">
                      <a-form-item :label="i18n('form.userId','用户ID')">
                          <a-input :placeholder="i18n('form.userId','用户ID','input')" v-model="queryParam.Q_USER_ID__S_LK"/>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item :label="i18n('form.isAdmin','是否超管')">
                          <a-input-number :min="0" :max="1000000" :placeholder="i18n('form.isAdmin','是否超管','input')"
                                          v-model="queryParam.Q_IS_ADMIN__I_EQ"/>
                      </a-form-item>
                    </a-col>
                <template v-if="advanced">

                </template>
                <a-col :md="8" :sm="24">
              <span class="table-page-search-submitButtons">
                <a-button @click="$refs.table.loadData()" icon="search" type="primary">{{$ti18('rxList.searchBtn','查询')}}</a-button>
                <a-button @click="resetSearch" style="margin-left: 4px">{{$ti18('rxList.resetBtn','重置')}}</a-button>
                <a @click="toggleAdvanced" style="margin-left: 8px">
                  {{ advanced ? $ti18('rxList.putAwayBtn','收起') : $ti18('rxList.openBtn','展开') }}
                  <a-icon :type="advanced ? 'up' : 'down'"/>
                </a>
              </span>
                </a-col>
              </a-row>
            </a-form>
          </div>
          <div class="table-operator">
            <rx-button alias="osInstUsersAdd" :butn-icon="'plus'" :butn-type="'primary'" :show-no-right="true" @click="add">{{$ti18('rxList.newBtn','新建')}}</rx-button>
            <rx-button v-if="editEnable && selectedRowKeys.length > 0" alias="osInstUsersEdit" :butn-icon="'edit'"
                       :butn-type="'primary'" :show-no-right="false" @click="editOne">{{$ti18('rxList.editBtn','编辑')}}</rx-button>

            <a-dropdown v-if="removeEnable && selectedRowKeys.length > 0">
              <rx-button alias="osInstUsersDelete" :butn-icon="'delete'" :butn-type="'danger'"
                         :show-no-right="false" @click="delByIds(selectedRowKeys)">{{$ti18('rxList.delBtn','删除')}}</rx-button>
            </a-dropdown>

          </div>
        </div>
        <rx-grid
                ref="table"
                :allowRowSelect="true"
                :multiSelect="true"
                :columns="columns"
                :defaultPageSize="10"
                url="/api-user/user/org/osInstUsers/query"
                :queryParam="queryParam"
                data-field="result.data"
                :pageSizeOptions="['10','30','40']"
                id-field="id"
                @selectChange="onSelectChange"
        >
          <span slot="action" slot-scope="{ text, record }" class="actionIcons">
            <span v-if="editEnable && showBtn(false)"  @click="edit(record)">{{$ti18('rxList.editBtn','编辑')}}</span>
            <span v-if="removeEnable && showBtn(false)"  @click="delByIds([record.id])">{{$ti18('rxList.delBtn','删除')}}</span>
          </span>
        </rx-grid>
      </rx-fit>
    </div>
  </rx-layout>
</template>

<script>
  import OsInstUsersApi from '@/api/user/org/osInstUsers'
  import OsInstUsersEdit from './OsInstUsersEdit'
  import {BaseList} from "@lowcode/jpaas-common-lib";
  export default {
    name: 'OsInstUsersList',
    mixins: [BaseList],
    data() {
      return {
        columns: [
          {
            title: this.$ti18('rxList.index','序号'),
            type: 'indexColumn',
            width: 100,
            dataIndex: 'serial',
            scopedSlots: {customRender: 'serial'}
          },
          {title: this.i18n('form.userId','用户ID'), dataIndex: 'userId', width: 100},
          {title: this.i18n('form.isAdmin','是否超管'), dataIndex: 'isAdmin', width: 100},
          {title: this.$ti18('rxList.action','操作'), width: 100, dataIndex: 'action', scopedSlots: {customRender: 'action'}}
        ],
        component:OsInstUsersEdit,
        comment:this.i18n('list.comment','租户关联用户表'),
        widthHeight:['800px','600px']
      }
    },
    methods:{
      i18n(name,text,key){
          return this.$ti18(name,text,"OsInstUsers",key);
      },
      delById(ids){
        return OsInstUsersApi.del({ ids: ids.join(',') });
      },
      getListByParams(parameter){
        return OsInstUsersApi.query(parameter)
      }
    }
  }
</script>
<style scoped>

</style>

